import { SpiritEquipBasePanel } from "./SpiritEquipBasePanel";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { EventName } from "../../mvc/EventName";
import { Cache } from "../../cache/Cache";
import { DataProvider } from "../../../../fl/data/DataProvider";
import { ItemData } from "../../resource/info/ItemData";
import { MsgManager } from "../../manager/MsgManager";
import { Language } from "../../../../extend/language/Language";
import { ObjCreate } from "../common/ObjCreate";
import { LoaderManager } from "../../../../com/gengine/resource/LoaderManager";
import { LoaderHelp } from "../../../common/display/LoaderHelp";
import { ResFileConst } from "../../resource/ResFileConst";
import { StrengthInfoPanel } from "./StrengthInfoPanel";
import { ImagesConst } from "../../resource/ImagesConst";
import { ImageInfo } from "../../../../com/gengine/resource/info/ImageInfo";
import { GlobalClass } from "../../../../com/mui/core/GlobalClass";
import { DataEvent } from "../../events/DataEvent";
//class SpiritEquipStrengthPanel
    
    export  class SpiritEquipStrengthPanel extends SpiritEquipBasePanel
    {
        constructor()
        {
            super();
            Dispatcher.addEventListener(EventName.SpiritEquipRemoveItem, this.onSpiritEquipRemoveItemHandler);
            return;
        }

        public /* override */ spiritEquipUpdate(): void
        {
            super.spiritEquipUpdate();
            return;
        }

        public /* override */ updateEquipList(): void
        {
            var loc1=Cache.instance.pack.rolePackCache.getSpiritEquipHDArray();
            _equipList.dataProvider = new DataProvider(loc1);
            return;
        }

        public updateStrengthData(arg1: ItemData): void
        {
            this._strengthInfoPanel.updateItemData(arg1);
            return;
        }

        protected /* override */ clickRightEquipItem(arg1: ItemData, arg2: Boolean=false): void
        {
            var loc1=arg1.itemExInfo.sp_act;
            if (loc1) 
            {
                this.updateStrengthData(arg1);
            }
            else 
            {
                MsgManager.showRollTipsMsg(Language.getString(36650));
            }
            return;
        }

        protected /* override */ createDisposedChildrenImpl(): void
        {
            this._strengthBg = ObjCreate.createBitmap(null, 0, 0, this);
            this._maxLevelBg = ObjCreate.createBitmap(null, 85, 115, this);
            this._costBg = ObjCreate.createBitmap(null, 151, 220, this);
            this._costBmp = ObjCreate.createBitmap(null, 160, 224, this);
            LoaderManager.instance.load("Equip_BigArrow.png", this.onBigArrowLoaded);
            LoaderHelp.addResCallBack(ResFileConst.SpiritEquipStrength, this.onResLoaded);
            var loc1=ObjCreate.createBg(5, 385, 385, 65, this);
            var loc2=ObjCreate.createTextArea("", 7, 385, 383, 65, this);
            loc2.text = Language.getString(36632);
            this._strengthInfoPanel = new StrengthInfoPanel();
            this._strengthInfoPanel.x = 10;
            this._strengthInfoPanel.y = 37;
            addChild(this._strengthInfoPanel);
            super.createDisposedChildrenImpl();
            ObjCreate.createGTextField(Language.getString(36639), 105, 25, 220, 50, _rightSprite, null, true, false);
            return;
        }

        protected /* override */ onResLoadedHandler(): void
        {
            super.onResLoadedHandler();
            ObjCreate.createBitmap(ImagesConst.SpiritEquipHDIcon, 10, 15, _rightSprite);
            ObjCreate.createBg(90, 5, 70, 1, _rightSprite, ImagesConst.SeptalLine).rotation = 90;
            return;
        }

        /* internal  */onBigArrowLoaded(arg1: ImageInfo): void
        {
            var loc1=null;
            loc1 = new Object /* flash.display.Bitmap */(arg1.bitmapData);
            loc1.x = 162;
            loc1.y = 161;
            this.addChild(loc1);
            return;
        }

        /* internal  */onResLoaded(): void
        {
            this._strengthBg.bitmapData = GlobalClass.getBitmapData(ImagesConst.SpiritEquipStrengthBg);
            this._maxLevelBg.bitmapData = GlobalClass.getBitmapData(ImagesConst.SpiritEquipStrengthLevel);
            this._costBg.bitmapData = GlobalClass.getBitmapData(ImagesConst.SpiritEquipStrengthCostBg);
            this._costBmp.bitmapData = GlobalClass.getBitmapData(ImagesConst.SpiritEquipStrengthCost);
            return;
        }

        /* internal  */onSpiritEquipRemoveItemHandler(arg1: DataEvent): void
        {
            _equipList.selectedIndex = -1;
            return;
        }

        /* internal */ /* var */_strengthBg: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_maxLevelBg: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_costBg: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_costBmp: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_hdIcon: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_strengthInfoPanel: StrengthInfoPanel;
    }
